import tkinter as tk
from views import AboutFrame,ChangeFrame,DeleteFrame,InsertFrame,SearchFrame
class MainPage:
    #:tk.Tk让编辑器自动补全
    def __init__(self,master:tk.Tk):
        self.root=master
        self.root.title('学生信息管理系统')
        self.root.geometry('600x400')
        self.create_page()

    def create_page(self):
        #关于页面
        self.about_frame=AboutFrame(self.root)
        #把这里面的逻辑都放到vies里了，给对象root加属性
        # tk.Label(self.about_frame,text='关于作品：本作品由tkinter制作').pack()
        # tk.Label(self.about_frame,text='关于作者：群里最弱的萌新').pack()
        # tk.Label(self.about_frame,text='版权所有：B站号').pack()
        #修改页面
        self.channge_frame=ChangeFrame(self.root)
        #tk.Label(self.channge_frame,text='修改页面').pack()
        self.delete_frame=DeleteFrame(self.root)
        self.search_frame=SearchFrame(self.root)
        self.insert_frame=InsertFrame(self.root)
        menubar=tk.Menu(self.root)
        #绑定点击事件
        menubar.add_command(label='录入',command=self.show_insert)
        menubar.add_command(label='查询',command=self.show_search)
        menubar.add_command(label='删除',command=self.show_delete)
        menubar.add_command(label='修改',command=self.show_change)
        menubar.add_command(label='关于',command=self.show_about)
        self.root['menu']=menubar

    def show_about(self):
        #不加pack()没法显示出来
        self.about_frame.pack()
        self.channge_frame.pack_forget()
        self.delete_frame.pack_forget()
        self.search_frame.pack_forget()
        self.insert_frame.pack_forget()

    def show_change(self):
        self.about_frame.pack_forget()
        self.channge_frame.pack()
        self.delete_frame.pack_forget()
        self.search_frame.pack_forget()
        self.insert_frame.pack_forget()

    def show_insert(self):
        self.about_frame.pack_forget()
        self.channge_frame.pack_forget()
        self.delete_frame.pack_forget()
        self.search_frame.pack_forget()
        self.insert_frame.pack()

    def show_search(self):
        self.about_frame.pack_forget()
        self.channge_frame.pack_forget()
        self.delete_frame.pack_forget()
        self.search_frame.pack()
        self.insert_frame.pack_forget()

    def show_delete(self):
        self.about_frame.pack_forget()
        self.channge_frame.pack_forget()
        self.delete_frame.pack()
        self.search_frame.pack_forget()
        self.insert_frame.pack_forget()

if __name__ == '__main__':
    root=tk.Tk()
    MainPage(root)
    root.mainloop()

